(function (vc, vm) {
    vc.extends({
        data: {
            editAccountWithdrawalApplyInfo: {
                applyId: '',
                amount: '',
                applyUserId: '',
                applyUserName: '',
                applyUserTel: '',
                context: ''
            }
        },
        _initMethod: function () {
        },
        _initEvent: function () {
            vc.on('editAccountWithdrawalApply', 'openEditAccountWithdrawalApplyModal', function (_params) {
                $that.refreshEditAccountWithdrawalApplyInfo();
                $('#editAccountWithdrawalApplyModel').modal('show');
                vc.copyObject(_params, $that.editAccountWithdrawalApplyInfo);
                $that.editAccountWithdrawalApplyInfo.communityId = vc.getCurrentCommunity().communityId;
            });
        },
        methods: {
            editAccountWithdrawalApplyValidate: function () {
                return vc.validate.validate({
                    editAccountWithdrawalApplyInfo: $that.editAccountWithdrawalApplyInfo
                }, {
                    'editAccountWithdrawalApplyInfo.amount': [
                        {
                            limit: "required",
                            param: "",
                            errInfo: "提现金额不能为空"
                        },
                        {
                            limit: "money",
                            param: "",
                            errInfo: "提现金额格式错误"
                        },
                    ],
                    'editAccountWithdrawalApplyInfo.applyUserId': [
                        {
                            limit: "required",
                            param: "",
                            errInfo: "申请人ID不能为空"
                        },
                        {
                            limit: "num",
                            param: "",
                            errInfo: "类型格式错误"
                        },
                    ],
                    'editAccountWithdrawalApplyInfo.applyUserName': [
                        {
                            limit: "required",
                            param: "",
                            errInfo: "申请人名称不能为空"
                        },
                        {
                            limit: "maxin",
                            param: "1,20",
                            errInfo: "申请人名称不能超过20位"
                        },
                    ],
                    'editAccountWithdrawalApplyInfo.applyUserTel': [
                        {
                            limit: "required",
                            param: "",
                            errInfo: "申请人电话不能为空"
                        },
                        {
                            limit: "phone",
                            param: "",
                            errInfo: "申请人电话格式错误"
                        },
                    ],
                    'editAccountWithdrawalApplyInfo.context': [
                        {
                            limit: "required",
                            param: "",
                            errInfo: "申请说明不能为空"
                        },
                        {
                            limit: "maxLength",
                            param: "500",
                            errInfo: "申请说明不能超过500"
                        },
                    ],
                    'editAccountWithdrawalApplyInfo.applyId': [
                        {
                            limit: "required",
                            param: "",
                            errInfo: "提现ID不能为空"
                        }
                    ]
                });
            },
            editAccountWithdrawalApply: function () {
                if (!$that.editAccountWithdrawalApplyValidate()) {
                    vc.toast(vc.validate.errInfo);
                    return;
                }
                vc.http.apiPost(
                    '/accountWithdrawalApply/upAccountWithdrawalApply',
                    JSON.stringify($that.editAccountWithdrawalApplyInfo),
                    {
                        emulateJSON: true
                    },
                    function (json, res) {
                        //vm.menus = vm.refreshMenuActive(JSON.parse(json),0);
                        let _json = JSON.parse(json);
                        if (_json.code == 0) {
                            //关闭model
                            $('#editAccountWithdrawalApplyModel').modal('hide');
                            vc.emit('accountWithdrawalApplyManage', 'listAccountWithdrawalApply', {});
                            vc.toast(_json.msg);
                            return;
                        }
                        vc.toast(_json.msg);
                    },
                    function (errInfo, error) {
                        console.log('请求失败处理');
                        vc.toast(errInfo);
                    });
            },
            refreshEditAccountWithdrawalApplyInfo: function () {
                $that.editAccountWithdrawalApplyInfo = {
                    applyId: '',
                    amount: '',
                    applyUserId: '',
                    applyUserName: '',
                    applyUserTel: '',
                    context: ''
                }
            }
        }
    });
})(window.vc, window.vc.component);
